using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using ComputerShopE3.Models;

namespace ComputerShopE3.Controllers
{
    public class TotalUpSalesController : Controller
    {
        //
        // GET: /TotalUpSales/
        ComputerShopDBEntities1 _db = new ComputerShopDBEntities1();


        public ActionResult Index()
        {
            int liststartY = 1988;
            int listendY = DateTime.Now.Year;
            List<string> listYear = new List<string>();
            for (int i = liststartY; i <= listendY; i++)
            {
                listYear.Add(i.ToString());
            }

            ViewData["StartYear"] = new SelectList(listYear);
            ViewData["EndYear"] = new SelectList(listYear);
            return View();
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(FormCollection form)
        {
            try
            {
                int startY = int.Parse(form.Get("StartYear"));
                int endY = int.Parse(form.Get("EndYear"));
                return RedirectToAction("TotalUpByYear", "TotalUpSales", new { startY, endY });
            }
            catch (Exception ex)
            {
                return View(ex.Message);
            }
        }

        public ActionResult TotalUpByYear(int startY, int endY)
        {
            ViewData["startY"] = startY;
            ViewData["endY"] = endY;
            ViewData.Model = _db.HOA_DON;
            return View();
        }
    }
}
